﻿# CMakeList.txt: CSVLiner 的 CMake 项目，在此处包括源代码并定义项目特定的逻辑。
cmake_minimum_required (VERSION 3.8)
if(WIN32)
    message("Cmake for WIN32")
    add_compile_options(/utf-8) #解决msvc乱码
elseif(UNIX)
    message("Cmake for UNIX")
else()
  # 其他系统下执行的代码
endif()
if (POLICY CMP0141)
  cmake_policy(SET CMP0141 NEW) # 如果支持，请为 MSVC 编译器启用热重载。
  set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

project ("CsvPlot" )

#vcpkg清单模式下的库安装位置，用于手动加入一些库 如qt csv无法按照官方推荐方式安装
set(MANIFEST_PATH ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET})
message("MANIFEST_PATH: "${MANIFEST_PATH})

set(CMAKE_AUTOMOC ON)               # 启用自动moc
set(CMAKE_AUTOUIC ON)               # 启用自动uic
set(CMAKE_AUTORCC ON)               # 启用自动rcc
set(CMAKE_INCLUDE_CURRENT_DIR ON)   # 启用自动包含当前目录
add_definitions(-DQWT_DLL)          # 定义 QWT_DLL 宏 否则无法使用qwt
find_package(qwt) # 没有代码提示，但是不报错
#include_directories(${MANIFEST_PATH}/include/qwt)
find_package(Qt5 COMPONENTS Core Widgets Gui PrintSupport Svg REQUIRED) # 引用Qt库

add_executable (CSVLiner 
    "CsvPlot.cpp" "CsvPlot.h" 
    "main.cpp")

#上面的官方方法，无法找到csv,h
#message("${MANIFEST_PATH}/include/csv.h")
#find_path(FAST_CPP_CSV_PARSER_INCLUDE_DIRS "D:/Code/VC/CSVLiner/out/build/x86-Release/vcpkg_installed/x86-windows/include/csv.h")
#target_include_directories(CSVLiner PRIVATE ${FAST_CPP_CSV_PARSER_INCLUDE_DIRS})
#message(${FAST_CPP_CSV_PARSER_INCLUDE_DIRS})
target_include_directories(CSVLiner PRIVATE "${MANIFEST_PATH}/include") 

include_directories(${MANIFEST_PATH}/include/qwt)

target_link_libraries(CSVLiner PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui Qt5::PrintSupport ${MANIFEST_PATH}/lib/qwt.lib
)

if (CMAKE_VERSION VERSION_GREATER 3.12)
  set_property(TARGET CSVLiner PROPERTY CXX_STANDARD 20)
endif()
# TODO: 如有需要，请添加测试并安装目标。

# 将源代码添加到此项目的可执行文件。修改不同的文件夹以编译不同的example。
aux_source_directory(examples/animation animationSrc)
add_executable (animation ${animationSrc})
target_link_libraries(animation PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib)

aux_source_directory(examples/barchart barchartSrc)
add_executable (barchart ${barchartSrc})
target_link_libraries(barchart PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib)

aux_source_directory(examples/bode bodeSrc)
add_executable (bode ${bodeSrc})
target_link_libraries(bode PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui Qt5::PrintSupport ${MANIFEST_PATH}/lib/qwt.lib)

aux_source_directory(examples/controls controlsSrc)
add_executable (controls ${controlsSrc})
target_link_libraries(controls PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib)

aux_source_directory(examples/cpuplot cpuplotSrc)
add_executable (cpuplot ${cpuplotSrc})
target_link_libraries(cpuplot PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib)

aux_source_directory(examples/curvedemo curvedemoSrc)
add_executable (curvedemo ${curvedemoSrc})
target_link_libraries(curvedemo PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib)

aux_source_directory(examples/dials dialsSrc)
add_executable (dials ${dialsSrc})
target_link_libraries(dials PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib)

aux_source_directory(examples/distrowatch distrowatchSrc)
add_executable (distrowatch ${distrowatchSrc})
target_link_libraries(distrowatch PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib)

aux_source_directory(examples/friedberg friedbergSrc)
add_executable (friedberg ${friedbergSrc})
target_link_libraries(friedberg PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib)

aux_source_directory(examples/itemeditor itemeditorSrc)
add_executable (itemeditor ${itemeditorSrc})
target_link_libraries(itemeditor PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib)

aux_source_directory(examples/legends legendsSrc)
add_executable (legends ${legendsSrc})
target_link_libraries(legends PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib)

aux_source_directory(examples/oscilloscope oscilloscopeSrc)
add_executable (oscilloscope ${oscilloscopeSrc})
target_link_libraries(oscilloscope PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/polardemo polardemoSrc)
add_executable (polardemo ${polardemoSrc})
target_link_libraries(polardemo PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui Qt5::PrintSupport ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/polarspectrogram polarspectrogramSrc)
add_executable (polarspectrogram ${polarspectrogramSrc})
target_link_libraries(polarspectrogram PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/radio radioSrc)
add_executable (radio ${radioSrc})
target_link_libraries(radio PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/rasterview rasterviewSrc)
add_executable (rasterview ${rasterviewSrc})
target_link_libraries(rasterview PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/realtime realtimeSrc)
add_executable (realtime ${realtimeSrc})
target_link_libraries(realtime PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/refreshtest refreshtestSrc)
add_executable (refreshtest ${refreshtestSrc})
target_link_libraries(refreshtest PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/scatterplot scatterplotSrc)
add_executable (scatterplot ${scatterplotSrc})
target_link_libraries(scatterplot PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/simpleplot simpleplotSrc)
add_executable (simpleplot ${simpleplotSrc})
target_link_libraries(simpleplot PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/sinusplot sinusplotSrc)
add_executable (sinusplot ${sinusplotSrc})
target_link_libraries(sinusplot PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/spectrogram spectrogramSrc)
add_executable (spectrogram ${spectrogramSrc})
target_link_libraries(spectrogram PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui Qt5::PrintSupport ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/splineeditor splineeditorSrc)
add_executable (splineeditor ${splineeditorSrc})
target_link_libraries(splineeditor PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui Qt5::PrintSupport ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/stockchart stockchartSrc)
add_executable (stockchart ${stockchartSrc})
target_link_libraries(stockchart PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/sysinfo sysinfoSrc)
add_executable (sysinfo ${sysinfoSrc})
target_link_libraries(sysinfo PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(examples/tvplot tvplotSrc)
add_executable (tvplot ${tvplotSrc})
target_link_libraries(tvplot PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(playground/curvetracker curvetrackerSrc)
add_executable (curvetracker ${curvetrackerSrc})
target_link_libraries(curvetracker PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(playground/graphicscale graphicscaleSrc)
add_executable (graphicscale ${graphicscaleSrc})
target_link_libraries(graphicscale PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Svg ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(playground/plotmatrix plotmatrixSrc)
add_executable (plotmatrix ${plotmatrixSrc})
target_link_libraries(plotmatrix PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(playground/rescaler rescalerSrc)
add_executable (rescaler ${rescalerSrc})
target_link_libraries(rescaler PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(playground/scaleengine scaleengineSrc)
add_executable (scaleengine ${scaleengineSrc})
target_link_libraries(scaleengine PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(playground/shapes shapesSrc)
add_executable (shapes ${shapesSrc})
target_link_libraries(shapes PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(playground/svgmap svgmapSrc)
add_executable (svgmap ${svgmapSrc})
target_link_libraries(svgmap PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Svg ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(playground/symbols symbolsSrc)
add_executable (symbols ${symbolsSrc})
target_link_libraries(symbols PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Svg ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(playground/timescale timescaleSrc)
add_executable (timescale ${timescaleSrc})
target_link_libraries(timescale PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )

aux_source_directory(playground/vectorfield vectorfieldSrc)
add_executable (vectorfield ${vectorfieldSrc})
target_link_libraries(vectorfield PRIVATE 
    Qt5::Core Qt5::Widgets Qt5::Gui ${MANIFEST_PATH}/lib/qwt.lib )
